package com.dkm.ec.product.persistence.dao.impl;

import com.dkm.base.db.mybatis.dao.MyBatisQueryDaoImpl;
import com.dkm.ec.product.persistence.dao.ProductEntityQueryDao;
import com.dkm.ec.product.persistence.entity.ProductEntityPo;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 对象功能:产品（抽象） QueryDao接口的实现
 * 开发公司:SKG.COM
 * 开发人员:颜超敏
 * 创建时间:2014-12-17 11:30:15
 */
@Repository
public class ProductEntityQueryDaoImpl extends MyBatisQueryDaoImpl<String, ProductEntityPo> implements ProductEntityQueryDao{

    @Override
    public String getNamespace() {
        return ProductEntityPo.class.getName();
    }
    
	public ProductEntityPo findByBusinessKey(String businessKey) {
		ProductEntityPo po =(ProductEntityPo)sqlSessionTemplate.selectOne(getNamespace() + ".findByBusinessKey", businessKey);
		return po;
	}

	@Override
	public List<ProductEntityPo> findProdRec(String userId, String productId,
			Integer count) {
		return findByKey("findProdRec", b().a("userId", userId).a("productId", productId).a("rowsCount", count).p());
	}

	@Override
	public List<ProductEntityPo> findByShopId(String shopId) {
		Map<String, Object> params = new HashMap<>();
		params.put("shopId", shopId);
		return findByKey("findByShopId", params);
	}


}
